var wait=60;//时间
function waittime(o,p) {//o为按钮的对象，p为可选，这里是60秒过后，提示文字的改变
	if (wait == 0) {
		o.removeAttr("disabled");
		o.val("点击发送验证码");//改变按钮中value的值
		p.html("如果您在1分钟内没有收到验证码，请检查您填写的手机号码是否正确或重新发送");
		wait = 60;
	} else {
		o.attr("disabled", true);//倒计时过程中禁止点击按钮
		o.val(wait + "(s)后重新获取");//改变按钮中value的值
		wait--;
		setTimeout(function() {
		    waittime(o,p);//循环调用
		},1000);
	}
} 
function sendSmsVerfy(){
	$("body").append("<img src='' />");
}

$(function(){	
	$("#sendmsg").click(function(){
		var thisobj=$(this);
		var oldvar=$('.number_pic').val();
		var ip=$('.ip').val();
		var token = $('.token').val();
		var newvar = oldvar+'|'+ip+'|'+token;
		if(newvar!=""){
			$.ajax({ 
				type: "get", 
				url: '/Cms/Helper/GetCode/mobile/'+newvar, 				
				dataType: "json", 
				success: function (data) { 
					//console.log(data);
				    if(data['err']){
				    	if(data['data'].length>0){
				    		$.Bfw.toastshow(data['data']); 
				    	}
					}else{
						$.Bfw.toastshow("发送成功");
						waittime(thisobj,$(".yzm"));
					}						
				}, 
				error: function (XMLHttpRequest, textStatus, errorThrown) { 
					$.Bfw.toastshow(errorThrown); 					
				} 
			});
		}
	});	
});
$(function(){	
	$("#sendpwd").click(function(){
		var thisobj=$(this);
		var oldvar=$('.number_pic').val();
		var ip=$('.ip').val();
		var token = $('.token').val()
		var newvar = oldvar+'|'+ip+'|'+token;
		if(newvar!=""){
			$.ajax({ 
				type: "get", 
				url: '/Cms/Helper/ChPhoneCode/mobile/'+newvar, 				
				dataType: "json", 
				success: function (data) { 
				    if(data['err']){
				    	if(data['data'].length>0){
							$.Bfw.toastshow(data['data']); 
						}
					}else{
						$.Bfw.toastshow("发送成功");
						waittime(thisobj,$(".yzm"));
					}						
				}, 
				error: function (XMLHttpRequest, textStatus, errorThrown) { 
					$.Bfw.toastshow(errorThrown); 					
				} 
			});
		}
	});	
});
var password =function(p,k){
    var str=md5(p).substr(3);
	str=str.substr(0,str.length-3);
	str = k.substr(0, 2) + str + k.substr(3, 5);
	str=md5(str);
	return str;
} 
/*function getToken(){
	$.ajax({ 
		type: "get", 
		url: '<?=Bfw::ACLINK("Member","GetFormToken")?>', 
		dataType: "json", 
		success: function (data) { 
			if(data['err']){
				alert(data['data']); 
			}else{
				encyptkey=data['data'];
			}				  
		}, 
		error: function (XMLHttpRequest, textStatus, errorThrown) { 				
			alert(errorThrown); 					
		} 
	});
}*/